package com.top.ruizhong.main.mine

import android.graphics.Typeface
import android.view.Gravity
import android.view.View
import android.widget.FrameLayout
import android.widget.LinearLayout
import android.widget.TextView
import com.blankj.utilcode.util.ColorUtils
import com.blankj.utilcode.util.ConvertUtils
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.module.lemlin.base.BaseAbstractFragment
import com.module.lemlin.custom.SpacingItemDecoration
import com.top.ruizhong.R
import kotlinx.android.synthetic.main.fragment_mine_video.*

class MineVideoFragment : BaseAbstractFragment() {


    companion object {
        fun newInstance(): MineVideoFragment {
            return MineVideoFragment()
        }
    }

    private val videoAdapter =
        object : BaseQuickAdapter<String, BaseViewHolder>(R.layout.item_video_mine) {
            override fun convert(holder: BaseViewHolder, item: String) {

            }
        }

    override val layoutResId: Int
        get() = R.layout.fragment_mine_video

    override fun initView() {
        rvMineVideoBody.apply {
            val decoration = SpacingItemDecoration(
                nSpan = 2,
                vGap = ConvertUtils.dp2px((10f)),
                hGap = ConvertUtils.dp2px((10f))
            )
            addItemDecoration(decoration)
        }.adapter = videoAdapter.apply {
            setFooterView(createFooterView())
        }
    }

    override fun initData() {
        val videos: MutableList<String> = mutableListOf()
        for (index in 0..10) {
            videos.add(index.toString())
        }
        videoAdapter.setNewInstance(videos)
    }

    private fun createFooterView(): View = TextView(requireContext()).apply {
        layoutParams = FrameLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT,
            ConvertUtils.dp2px(60f)
        )
        gravity = Gravity.CENTER
        textSize = 13f
        setTypeface(null, Typeface.BOLD)
        setTextColor(ColorUtils.getColor(R.color.FF_666666))
    }

}